<?php

namespace app\api\controller;

use app\home\model\LimitAmountConfig;
use Exception;
use think\Controller;

class Conf extends Controller
{
    
    public function common_channel(){
       
        header('Content-Type: text/html;charset=utf-8');
        header('Access-Control-Allow-Origin:*'); // *代表允许任何网址请求
        header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'); // 允许请求的类型
        header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
        header('Access-Control-Allow-Headers: Content-Type,Content-Length,Accept-Encoding,X-Requested-with, Origin'); // 设置允许自定义请求头的字段
 
        $config = db('spreader_config','db_qpplatformdb')->where('SpreaderID','=',-2)->value('Config');
    
        if(empty($config)){
            throw new Exception("conf not found");
        }
        exit($config);

    }

    public function common_game(){
        $limit_amount = (new LimitAmountConfig)->getAllConf();

        return json_encode([
            'limit_amount' => $limit_amount
        ]);
    }

    public function common_conf(){

        $server_config_info = db('server_config_info','db_config2')->field('ID,Content')->whereIn('ID',['1011','1012','1013','1014'])->select();
        $data = [];
        foreach($server_config_info as $k=>$v){
            // $data[$v['ID']] =  json_decode($v['Content'],true);
            $data[$v['ID']] =  $v['Content'];

        }
        exit( json_encode(['limit_amount'=>$data]));
    }


}


